/*
 * Copyright (C) 2008, Velocityme Partnership
 * ShowDefaultAction.java
 *
 * Created on 30 August 2008, 21:10
 */

package com.velocityme.www.interfaces;

//web imports
import com.velocityme.valueobjects.NodeValue;
import com.velocityme.www.actionforms.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;

//ejb interfaces
import com.velocityme.interfaces.*;

/**
 *
 * @author  Robert
 */
public class ShowBurnDownAction extends org.apache.struts.action.Action {
    
    /** Creates a new instance of ShowBurnDownAction */
    public ShowBurnDownAction() {
    }
    
    /** Set nodePK in request */
    public ActionForward execute(ActionMapping mapping, 
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws Exception {
        NodeIdActionForm node = (NodeIdActionForm)form;
        HttpSession session = request.getSession();
        KeySession key = (KeySession) session.getAttribute("sessionKey");
        RemoteClientSession cs = RemoteClientSessionUtil.getHome().create();
        if (node.getNodeId() == 0)
            node.setNodeId(((Integer)session.getAttribute("nodeId")).intValue());
        NodePK nodePK = new NodePK(new Integer(node.getNodeId()));
        request.setAttribute("nodePK", nodePK);
        NodeValue nodeValue = cs.getNodeValue(key, nodePK);
        if (nodeValue.getType().equals("Sprint"))
            return mapping.findForward("ACTION_SPRINT_SUCCESS");
        return mapping.findForward("ACTION_TASK_SUCCESS");
    }
        
}
